#define _CRT_SECURE_NO_WARNINGS 1
#include"BinaryTree.h"

BTNode* BuyNode(BTDataType x)
{
	BTNode* node = (BTNode*)malloc(sizeof(BTNode));
	if (node == NULL)
	{
		perror("BTNode malloc fail!");
		return NULL;
	}
	node->data = x;
	node->left = node->right = NULL;
	return node;
}

BTNode* CreatBinaryTree()
{
	BTNode* node1 = BuyNode(1);
	BTNode* node2 = BuyNode(2);
	BTNode* node3 = BuyNode(3);
	BTNode* node4 = BuyNode(4);
	BTNode* node5 = BuyNode(5);
	BTNode* node6 = BuyNode(6);
	BTNode* node7 = BuyNode(7);

	node1->left = node2;
	node1->right = node4;
	node2->left = node3;
	node4->left = node5;
	node4->right = node6;
	//node5->right = node7;
	node2->right = node6;
	return node1;
}

int main()
{
	BTNode* root = CreatBinaryTree();
	//BinaryTreePrevOrder(root);
	//BinaryTreePostOrder(root);
	//int size = BinaryTreeSize(root);
	//printf("%d\n", size);
	//int leafnum = BinaryTreeLeafSize(root);
	//printf("%d\n", leafnum);
	//int TreeHeight = BinaryTreeHeight(root);
	//int num = BinaryTreeLevelKSize(root, 1);
	//printf("%d\n", num);

	//BTNode* ret = BinaryTreeFind(root, 1);
	//char arr[] = "ABD##E#H##CF##G##";
	//int i = 0;
	//BTNode* node = BinaryTreeCreate(arr, &i);
	//BinaryTreePrevOrder(node);

	//BinaryTreeLevelOrder(root);
	int ret = BinaryTreeComplete(root);
	if (ret)
	{
		printf("YES\n");
	}
	else
	{
		printf("NO\n");
	}
	return 0;
}